<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>
        <h1 class="pull-right" id="dberp-menu-top">
            <?php echo $this->HelpUrl('reportStock'); ?>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <h2 class="page-header">
                            <?php echo $this->translate('库存报表'); ?>
                        </h2>

                        <div class="row" style="padding-bottom: 15px;">
                            <?php if (!empty($this->warehouseArray)) foreach ($this->warehouseArray as $warehouseValue) { ?>
                            <div class="col-xs-3">
                                <div class="col-sm-12">
                                    <strong><?php echo $warehouseValue['warehouseName']; ?>：</strong>
                                    <?php echo $this->translate('商品库存'); ?> <?php echo $warehouseValue['goodsNum']; ?>&nbsp;&nbsp;&nbsp;
                                    <?php echo $this->translate('商品'); ?> <?php echo $warehouseValue['goodsType']; ?>

                                </div>
                            </div>
                            <?php } ?>
                        </div>

                    </div>

                    <div class="box-body table-responsive no-padding">
                        <table class="table erp-table table-hover">
                            <thead>
                            <tr class="erp-bg-thead">
                                <th style="width: 30%"><?php echo $this->translate('商品名称'); ?></th>
                                <th style="width: 20%"><?php echo $this->translate('商品编号'); ?></th>
                                <th style="width: 10%"><?php echo $this->translate('商品规格'); ?></th>
                                <th style="width: 10%"><?php echo $this->translate('库存'); ?></th>
                                <th style="width: 20%"><?php echo $this->translate('仓库'); ?></th>
                                <th style="width: 10%"></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_number')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_number'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_spec')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_spec'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_stock')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_stock')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_stock'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_stock'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('warehouse_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('warehouse_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php
                                    $formData = $sForm->getData();
                                    if(!empty(array_filter($formData))) { ?>
                                    <a href="<?php echo $this->url('report-stock');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>
                            <tbody>
                            <?php
                            if ($this->warehouseGoodsList) foreach ($this->warehouseGoodsList as $goodsValue) {?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($goodsValue['goodsName']); ?></td>
                                    <td><?php echo $this->escapeHtml($goodsValue['goodsNumber']); ?></td>
                                    <td><?php echo $this->escapeHtml($goodsValue['goodsSpec']); ?></td>
                                    <td><?php echo $goodsValue[0]->getWarehouseGoodsStock(); ?></td>
                                    <td colspan="2"><?php echo $this->escapeHtml($goodsValue[0]->getOneWarehouse()->getWarehouseName()); ?></td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->warehouseGoodsList, 'Sliding', 'layout/page', ['route' => 'report-stock']); ?>
                    </div>

                </div>
            </div>
        </div>

    </section>
</div>